﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace UpdaterForm
{
    class DirectoryHelper
    {
        private static List<DirectoryInfo> SortDirectoryes(DirectoryInfo dir)
        {
           var dirs = dir.GetDirectories().ToList();
            //TODO:nahuja sortirovat esli i tak oni sortirovani?
            dirs.Sort(new DateFolderComparer());
            return dirs;
        }

        public static List<DirectoryInfo> GetDirs(DirectoryInfo dir)
        {
            return SortDirectoryes(dir);
        }
    }

    class DateFolderComparer : Comparer<DirectoryInfo>
    {
        public override int Compare(DirectoryInfo x, DirectoryInfo y)
        {
            if (x != null && y != null) 
                return String.Compare(x.Name, y.Name, StringComparison.Ordinal);
            return 0;
        }
    }
}
